
//针对需要识别用户第一次输入行为的打点日志事件，并且只执行一次
var SDOLOG_onFirstChange = function(e) {
    if(e.type == 'propertychange' && e.originalEvent.propertyName !== "value" )
      return;
    var el = e.target;
    //var str = $(el).attr("data-log");
    var itemId = $(el).attr("id");
    //获取当前页签
    var curRegType = $(".mod_regist_nav .cur").attr('name');
    //console.log(curRegType)
    if(itemId){
    	
    	//根据不同的注册页签来区分日志内容
    	switch(curRegType){
        case "registPhone" :
            //手机注册
    		//国外手机
    		if($(".selcountry").is(":visible"))
    		{
    			switch(itemId)
            	{
	        		case "mobile":
	        			clog("overseas_inputphone");
	        			break;
	        		case "password":
	        			clog("overseas_inputpwd");
	        			break;
	        		case "btnShowPass":
	        			clog("overseas_clickshowpwd");
	        			break;
	        		case "checkCode":
	        			clog("overseas_inputsmscode");
	        			break;
	        		case "submit":
	        			clog("overseas_clicksubmit");
	        			break;
            	}
    		}
    		else
    		{
    			switch(itemId)
            	{
	        		case "mobile":
	        			clog("phone_inputphone");
	        			break;
	        		case "password":
	        			clog("phone_inputpwd");
	        			break;
	        		case "btnShowPass":
	        			clog("phone_clickshowpwd");
	        			break;
	        		case "checkCode":
	        			clog("phone_inputsmscode");
	        			break;
	        		case "realname":
	        			clog("phone_inputrealname");
	        			break;
	        		case "idCard":
	        			clog("phone_inputidcard");
	        			break;
	        		case "submit":
	        			clog("phone_clicksubmit");
	        			break;
            	}
    		}
            break;
        case "registMail" :
            //邮件注册
        	switch(itemId)
        	{
        		case "email":clog("email_inputemail");break;
        		case "password":clog("email_inputpwd");break;
        		case "btnShowPass":clog("email_clickshowpwd");break;
        		case "realname":clog("email_inputrealname");break;
        		case "idCard":clog("email_inputidcard");break;
        		case "submit":clog("email_clicksubmit");break;
        	}
            break;
        case "registCustom" :
            //个性注册
        	switch(itemId)
        	{
        		case "username":clog("pt_inputusername");break;
        		case "password":clog("pt_inputpwd");break;
        		case "btnShowPass":clog("pt_clickshowpwd");break;
        		case "realname":clog("pt_inputrealname");break;
        		case "idCard":clog("pt_inputidcard");break;
        		case "realEmail":clog("pt_inputrealemail");break;
        		case "submit":clog("pt_clicksubmit");break;
        	}
            break;
    	}
    }
 }


var SDOLOG_onClick = function(e) {
    var el = e.target;
    //var str = $(el).attr("data-log");
    var itemId = $(el).attr("id");
    //获取当前页签
    var curRegType = $(".mod_regist_nav .cur").attr('name');
    if(itemId){
    	if(itemId == 'linkShowContrast'){
    		common_log('ShowContrast');
    	}
    	//根据不同的注册页签来区分日志内容
    	switch(curRegType){
        case "registPhone" :
            //手机注册
    		//国外手机
    		if($(".selcountry").is(":visible"))
    		{
    			switch(itemId)
            	{
	        		case "btnShowPass":
	        			var $input = $(".showPassBtn").parent().find("input");
	        			if($input.attr("type")==="password"){
	        				clog("overseas_clickshowpwd");
	        			}
	        			else{
	        				clog("overseas_clickhidepwd");
	        			}
	        			break;
	        		case "submit":
	        			clog("overseas_clicksubmit");
	        			break;
	        		case "js_get_phone":
	        			clog("overseas_getsmscode");
	        			break;
            	}
    		}
    		else
    		{
    			switch(itemId)
            	{
	        		case "btnShowPass":
	        			var $input = $(".showPassBtn").parent().find("input");
	        			if($input.attr("type")==="password"){
	        				clog("phone_clickshowpwd");
	        			}
	        			else{
	        				clog("phone_clickhidepwd");
	        			}
	        			break;
	        		case "submit":
	        			clog("phone_clicksubmit");
	        			break;
	        		case "js_get_phone":
	        			clog("phone_getsmscode");
	        			break;
            	}
    		}
            break;
        case "registMail" :
            //邮件注册
        	switch(itemId)
        	{
        		case "btnShowPass":
        			var $input = $(".showPassBtn").parent().find("input");
        			if($input.attr("type")==="password"){
        				clog("email_clickshowpwd");
        			}
        			else{
        				clog("email_clickhidepwd");
        			}
        			break;
        		case "submit":
        			clog("email_clicksubmit");
        			break;
        	}
            break;
        case "registCustom" :
            //个性注册
        	switch(itemId)
        	{
        		case "btnShowPass":
        			var $input = $(".showPassBtn").parent().find("input");
        			if($input.attr("type")==="password"){
        				clog("pt_clickshowpwd");
        			}
        			else{
        				clog("pt_clickhidepwd");
        			}
        			break;
        		case "submit":
        			clog("pt_clicksubmit");
        			break;
        	}
            break;
    	}
    }
 }

var SDOLOG_onPageView = function(e) {
    //获取当前页签
	var curRegType = $(".mod_regist_nav .cur").attr('name');
	
	var itemId = "";
	if(e){
		var el = e.target;
	    itemId = $(el).attr("id");
	}

    //根据不同的注册页签来区分日志内容
	switch(curRegType){
    case "registPhone" :
        //手机注册
		if($(".selcountry").is(":visible"))
		{    		
			if(itemId == "js_get_flags"){
				clog("pageview_phone");
			}
			else{
				clog("pageview_overseas");
			}
		}
		else
		{
			if(itemId == "js_get_flags"){
				clog("pageview_overseas");
			}
			else{
				clog("pageview_phone");
			}
		}
        break;
    case "registMail" :
        //邮件注册
    	clog("pageview_email");
        break;
    case "registCustom" :
        //个性注册
    	clog("pageview_pt");
        break;
	}

 }


function common_log(msg){
	var curRegType = $(".mod_regist_nav .cur").attr('name');
	//根据不同的注册页签来区分日志内容
	switch(curRegType){
	    case "registPhone" :
	        //手机注册
			if($(".selcountry").is(":visible"))
			{    		
				clog("overseas_" + msg);
			}
			else
			{
				clog("phone_" + msg);
			}
	        break;
	    case "registMail" :
	    	clog("email_" + msg);
	        break;
	    case "registCustom" :
	    	clog("pt_" + msg);
	        break;
	}
}

var isSendSMSLogTime = false;
var SDOLOG_onLogTime = function(e){
	var el = e.target;
    //var str = $(el).attr("data-log");
    var itemId = $(el).attr("id");
    if(itemId == "checkCode"){
    	if(isSendSMSLogTime){
        	if(time_BeginSMS){
            	if($('#js_get_phone').hasClass("smscodesendloop")
            			|| !$('#js_get_phone').hasClass("wait")){
                	//为处理时长日志，这里需要加入时间记录,BY PXM
                	time_EndCheckSMSCode = new Date().getTime();
            		//记录时长日志
                	LoginLog.Log('CheckSMSCode&time_BeginSMS=' + time_BeginSMS + '&time_EndCheckSMSCode=' + time_EndCheckSMSCode);
                	isSendSMSLogTime = true;
            	}
        	}
    	}
    }
}


$(document).ready(function() {
	//注册所有打点控件的事件
    $("#mobile,#email,#username,#password,#checkCode,#realname,#idCard,#realEmail,#validateCode").one("input", SDOLOG_onFirstChange);
	$("#mobile,#email,#username,#password,#checkCode,#realname,#idCard,#realEmail,#validateCode").one("propertychange", SDOLOG_onFirstChange);
	$("#btnShowPass,#submit,#js_get_phone,#register_app_1,#linkShowContrast").click(SDOLOG_onClick);
	//处理pageview打点信息
	$(".mod_regist_nav li").click(SDOLOG_onPageView);
	$(".js_get_flags").click(SDOLOG_onPageView);
	$("#checkCode").blur(SDOLOG_onLogTime);
	//每次加载默认执行次打点
	SDOLOG_onPageView();
});





